package com.bykj.property.mapper.provider;

import com.bykj.property.controller.vo.request.PmProprietorPageRequest;
import com.bykj.property.controller.vo.request.PmUnitPageRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.jdbc.SQL;

/**
 * @author yiming
 * @title: PmUnitSql
 * @projectName property
 * @description: TODO
 * @date 2019/6/3017:22
 */
public class PmUnitSql {
    public String getSql(PmUnitPageRequest pageRequest){
        return new SQL() {
            {
                SELECT("*");
                FROM("pm_unit");

                if(pageRequest.getPmVillageId()!=null) {

                    WHERE("pm_village_id = #{pmVillageId}");
                }
                if(!StringUtils.isEmpty(pageRequest.getUnName())) {
                    pageRequest.setUnName("%"+pageRequest.getUnName()+"%");
                    WHERE("charge_name like #{chargeName}");
                    WHERE("un_name = #{unName}");
                }

            }
        }.toString();

    }
}
